package com.twu.biblioteca.login;

import com.twu.biblioteca.options.Option;

import java.io.IOException;

public class LoginFilter {
    LoginInterceptorMatcher loginInterceptorMatcher = new LoginInterceptorMatcher();
    LoginInterceptor loginInterceptor = new LoginInterceptor();

    public void setLoginInterceptorMatcher(LoginInterceptorMatcher loginInterceptorMatcher) {
        this.loginInterceptorMatcher = loginInterceptorMatcher;
    }

    public void setLoginInterceptor(LoginInterceptor loginInterceptor) {
        this.loginInterceptor = loginInterceptor;
    }

    public void doFilter(Option option) throws IOException {
        if (loginInterceptorMatcher.matches(option)) {
            loginInterceptor.login();
        }
    }
}
